


import pygame
import sys

from pygame.locals import *

pygame.init()

size=width,height=200,400
screen=pygame.display.set_mode(size)

pygame.display.set_caption("我是event") 

bg=(0,0,0)


font=pygame.font.SysFont("arial",20)
line_height=font.get_linesize()
position=0


screen.fill(bg)

while True:
    
    for e in pygame.event.get():
        
        if(e.type==QUIT):
            sys.exit()

        if e.type== KEYDOWN:
            if(e.key==K_LEFT):
                
                screen.blit(
                    font.render(
                        "keydown",
                        True,
                        (0,255,0)
                    ),
                    (0,position)
                )

        position+=line_height

        if position>height:
            position=0
            screen.fill(bg)

    pygame.display.flip()